package homework;

public class Person {
    String name;//姓名
    int age;
    boolean gender;//性别 ture为男性
    boolean partner;//是否结婚 ture为结婚

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean isGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public boolean isPartner() {
        return partner;
    }

    public void setPartner(boolean partner) {
        this.partner = partner;
    }

    public Person(String name, int age, boolean gender, boolean partner) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.partner = partner;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Person{");
        sb.append("name='").append(name).append('\'');
        sb.append(", age=").append(age);
        sb.append(", gender=").append(gender);
        sb.append(", partner=").append(partner);
        sb.append('}');
        return sb.toString();
    }

    //写if判断语句
public  void marry(Person P1,Person P2){
        if((P1.partner==false&&P2.partner==false)&&(P1.isGender()!=P2.isGender())){
            if((P1.isGender()==true&&P1.getAge()>=24 ) &&(P2.isGender()==false&&P2.getAge()>=22) ||
                    (P1.isGender()==false&&P1.getAge()>=22 ) &&(P2.isGender()==true&&P2.getAge()>=24)){
                System.out.println(P1.getName()+"和"+P2.getName()+"能结婚");

            }else

            System.out.println(P1.getName()+"和"+P2.getName()+"不能结婚");
        }
        else
    System.out.println(P1.getName()+"和"+P2.getName()+"不能结婚");
}



}
